package top.laoshuzi.common.utils.pojo.page;

import java.util.ArrayList;
import java.util.List;

public class PageContent<T> {

    private List<Page<T>> dtoPageList = new ArrayList<>();
    private List<T> dtoList = new ArrayList<>();

    public void add(Page<T> page) {
        dtoPageList.add(page);
        dtoList.addAll(page.getContent());
    }

    public void reset() {
        dtoList.clear();
        dtoPageList.clear();
    }

    public boolean hasNext() {
        if (dtoPageList.isEmpty())
            return true;
        return !dtoPageList.get(dtoPageList.size() - 1).isLast();
    }

    public int getNumber() {
//            if (dtoPageList.isEmpty())
//                return 0;
//            return dtoPageList.get(dtoPageList.size() - 1).getNumber();
        return dtoPageList.size();
    }

    public List<Page<T>> getDtoPageList() {
        return dtoPageList;
    }

    public List<T> getDtoList() {
        return dtoList;
    }
}
